package com.depth.viewer.widget
{
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	public class BaseWidgetMediator extends Mediator
	{
		private var _listNotificationInterests:Function;
		private var _handleNotification:Function;
		
		/**
		 * 用于配合IBaseMeditorWidget监听消息的监听器。
		 * @param mediatorName  //一般传widgetId，框架会自动计算出相应的mediatorName 格式为：传入的widgetId + "_" + mediator,如："layerManagerWidget_mediator"
		 * @param viewComponent widget自身的引用
		 * @param listNotificationInterests 此widget可以监听的消息 名称列表
		 * @param handleNotification  当接收到消息列表中所列的任何一消息时会调用此方法，此方法必须具有以下签名：
		 * 			function handleNotification(notification:INotification):void{
		 * 	
		 * 			}
		 * 
		 */		
		public function BaseWidgetMediator(mediatorName:String=null, viewComponent:Object=null,listNotificationInterests:Function = null,handleNotification:Function = null)
		{
			mediatorName += (mediatorName + "_" + "mediator");
			super(mediatorName, viewComponent);
			this._handleNotification = handleNotification;
			this._listNotificationInterests = listNotificationInterests;
		}
		
		override public function listNotificationInterests():Array{
			if(_listNotificationInterests){
				return _listNotificationInterests();
			}else{
				return [];
			}
		}
		override public function handleNotification(notification:INotification):void{
			if(_handleNotification){
				_handleNotification(notification);
			}
		}
	}
}